(*
 *      File:         EasyRexx.h
 *      Description:  Headerfile for the easyrexx.library
 *
 *      (C) 1994,1995 Ketil Hunn
 *
 *      Translation for Benchmark M2 110295 - Tom Breeden, tmb@virginia.edu
 *)

DEFINITION MODULE EasyRexx;

FROM SYSTEM IMPORT ADDRESS, BYTE;

(*** PRIVATE INCLUDES ****************************************************************)
FROM Libraries   IMPORT LibraryPtr;
FROM Ports       IMPORT MsgPortPtr;
FROM Tasks       IMPORT SignalSet;
FROM Utility     IMPORT Tag, TagItemPtr, TagUser;

(*** DEFINES *************************************************************************)
CONST EasyRexxName        = "easyrexx.library";
      EasyRexxVersion     = 3D;

VAR   EasyRexxBase        :LibraryPtr;

TYPE  CharPointer = POINTER TO CHAR;

      ARexxContext;
      ARexxCommandShell;

CONST NULLARexxContext = ARexxContext(NIL);

TYPE ARexxCommandTable = RECORD
                           id            :LONGINT;       (* NOTE: do not use an id of 0 *)
                           command,
                           cmdtemplate   :CharPointer;
                           userdata      :ADDRESS;
                         END;
     ARexxCommandTablePtr = POINTER TO ARexxCommandTable;


(* V3.0 *****************************************************************************)

TYPE ARexxMacro;

     ARexxFunc = PROCEDURE(ARexxContext):INTEGER;

CONST NULLARexxMacro = ARexxMacro(NIL);

CONST ERRecordPointerWidth  = 16;
      ERRecordPointerHeight = 17;
      ERRecordPointerOffset = -1;

(***** TAGS *************************************************************************)

CONST ERTagBase             = TagUser;
      ERPortname            = ERTagBase+Tag(1);  (* Name of AREXX port                   *)
      ERCommandTable        = ERTagBase+Tag(2);  (* Table of supported AREXX commands    *)
      ERReturnCode          = ERTagBase+Tag(3);  (* Primary result (return code)         *)
      ERResult              = ERReturnCode;      (* Alias for ERReturnCode               *)
      ERResult1             = ERReturnCode;      (* Alias for ERReturnCode               *)
      ERResult2             = ERTagBase+Tag(4);  (* Secondary result (string)            *)
      ERPort                = ERTagBase+Tag(5);  (* Use already created port             *)
      ERResultString        = ERTagBase+Tag(6);  (* Secondary result (string)            *)
      ERResultLong          = ERTagBase+Tag(7);  (* Secondary result (long)              *)

(***** EASYREXX V2 TAGS ***********************************************************)
CONST ERAsynch              = ERTagBase+Tag(8);  (* Send ARexx command asyncronously     *)
      ERContext             = ERTagBase+Tag(9);  (* Pointer to an ARexxContext           *)
      ERAuthor              = ERTagBase+Tag(10); (* Pointer to an author string          *)
      ERCopyright           = ERTagBase+Tag(11); (* Pointer to an copyright string       *)
      ERVersion             = ERTagBase+Tag(12); (* Pointer to an version string         *)
      ERPrompt              = ERTagBase+Tag(13); (* Pointer to a prompt string           *)
      ERClose               = ERTagBase+Tag(14); (* Close CommandShell                   *)
      ERErrorMessage        = ERTagBase+Tag(15); (* Pointer to an error message          *)
      ERFlags               = ERTagBase+Tag(16); (* LONG of flags                        *)
      ERFont                = ERTagBase+Tag(17); (* Pointer to a struct TextFont *       *)

(***** EASYREXX V3 TAGS ***********************************************************)
CONST ERMacro               = ERTagBase+Tag(18); (* Pointer to ARexxMacro                *)
      ERMacroFile           = ERTagBase+Tag(19); (* Pointer to a macrofile               *)
      ERRecord              = ERTagBase+Tag(20); (* Really record macro command          *)
      ERFile                = ERTagBase+Tag(21); (* Send file                            *)
      ERString              = ERTagBase+Tag(22); (* Send string                          *)
      ERCommand             = ERTagBase+Tag(23); (* Pointer to commandstring             *)
      ERArguments           = ERTagBase+Tag(24); (* Var-array of arguments               *)
      ERArgument            = ERArguments;
      ERArgumentsLength     = ERTagBase+Tag(25); (* CharLength of command+arguments      *)
      ERArgumentLength      = ERArgumentsLength;

(************************************************************************************)

(*** EASYREXX "MACROS" ***************************************************************)

 PROCEDURE ERShellSignals(context:ARexxContext):SignalSet;
 PROCEDURE ERSignals(context:ARexxContext):SignalSet;
 PROCEDURE ERSignal(context:ARexxContext):SignalSet;

 PROCEDURE ERSafeToQuit(context:ARexxContext):BOOLEAN;
 PROCEDURE ERSetSignals(context:ARexxContext; s:SignalSet);
 PROCEDURE ERIsShellOpen(context:ARexxContext):BOOLEAN;

 PROCEDURE Id(context:ARexxContext):LONGINT;
 PROCEDURE Port(context:ARexxContext):MsgPortPtr;
 PROCEDURE Portname(context:ARexxContext; VAR nam:ARRAY OF CHAR);
 PROCEDURE Table(context:ARexxContext; i:INTEGER):ARexxCommandTablePtr;

 PROCEDURE Arg(context:ARexxContext; i:INTEGER):ADDRESS;
 PROCEDURE ArgNumber(context:ARexxContext; i:INTEGER):LONGINT;
 PROCEDURE ArgString(context:ARexxContext; i:INTEGER):CharPointer;
 PROCEDURE ArgBool(context:ARexxContext; i:INTEGER):BOOLEAN;

 PROCEDURE GetRC(context:ARexxContext):LONGINT;
 PROCEDURE GetResult1(context:ARexxContext):LONGINT;
 PROCEDURE GetResult2(context:ARexxContext):LONGINT;

 PROCEDURE TableEnd(VAR entry:ARexxCommandTable);

 PROCEDURE CreateERRecordPointer():ADDRESS;   (*V3*)
 PROCEDURE FreeERRecordPointer();             (*V3*)

(*** PROTOTYPES **********************************************************************)

 PROCEDURE FreeARexxContext(context:ARexxContext);
 PROCEDURE AllocARexxContextA(taglist:TagItemPtr):ARexxContext;
 PROCEDURE GetARexxMsg(context:ARexxContext):BYTE;
 PROCEDURE SendARexxCommandA(command:CharPointer; taglist:TagItemPtr):LONGINT;
 PROCEDURE ReplyARexxMsgA(context:ARexxContext; taglist:TagItemPtr);

(*** PROTOTYPES V2.0 *****************************************************************)

 PROCEDURE ARexxCommandShellA(context:ARexxContext; taglist:TagItemPtr):BYTE;

(*** PROTOTYPES V3.0 *****************************************************************)

 PROCEDURE AllocARexxMacroA(taglist:TagItemPtr):ARexxMacro;
 PROCEDURE IsARexxMacroEmpty(macro:ARexxMacro):BYTE;
 PROCEDURE ClearARexxMacro(macro:ARexxMacro);
 PROCEDURE FreeARexxMacro(macro:ARexxMacro);
 PROCEDURE AddARexxMacroCommandA(macro:ARexxMacro; taglist:TagItemPtr):BYTE;
 PROCEDURE WriteARexxMacroA(context:ARexxContext; macro:ARexxMacro; macroname:CharPointer;
                            taglist:TagItemPtr):BYTE;
 PROCEDURE RunARexxMacroA(context:ARexxContext; taglist:TagItemPtr):BYTE;
 PROCEDURE CreateARexxStemA(context:ARexxContext; stemname:CharPointer;
                            VAR vars:ARRAY OF CharPointer):BYTE;

END EasyRexx.
